#ifndef KDTREE_H
#define KDTREE_H

#include "opencv2/opencv.hpp"
#include <vector>

using namespace std;

struct KDRow
{
    int originalIdx;
    cv::Mat rowData;
};

struct KDNode
{
    static int node_counter;

    KDNode() : is_leaf(false),value(0), left_node(NULL), right_node(NULL)
    {
        node_counter++;
    }

    ~KDNode()
    {
        node_counter--;
    }

    int originalIdx;
    int axis;
    bool is_leaf;

    float value;

    KDNode * left_node;
    KDNode * right_node;
};

class KDTree
{
    KDNode * root_node;

public:

    KDTree(const cv::Mat & desc);
    ~KDTree();

    void match(const cv::Mat & original, const cv::Mat & target, std::vector<cv::DMatch>& match_result, float maxDistance);
};

#endif // KDTREE_H
